#ifndef WORKHISFORM_H
#define WORKHISFORM_H

#include <QWidget>
#include <QDialog>
#include <QScrollBar>
#include <SqliteUtil/sqliteutil.h>
#include <QDebug>
#include <QGraphicsDropShadowEffect>
#include <QListView>
#include <QMessageBox>
#include <QDir>
#include <QThread>
#include <QDateTime>
#include "Message/message.h"

#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>


#include "from/progressbarwidget.h"

#include "SqliteUtil/sqliteutil.h"

#define _PAGE_NUM_ 100      // 表格每页有多少数据

namespace Ui {
class WorkHisForm;
}

class WorkHisAvgThread;

class WorkHisForm : public QDialog
{
    Q_OBJECT

public:
    explicit WorkHisForm(QWidget *parent = nullptr);
    ~WorkHisForm();

    void updateHistoryData();
    void clearTableWidget();
    void setBatchIDName(int id, QString batchName);
    void setCustomerName(QString name);


signals:
    void signal_CalcAvg(QList<T_BatchLine> &list);

public slots:
    void OnSlideAction(int nRowIndex);


private:
    void init_connectSigSlot();
    void setTableData(const QList<T_BatchLine> &list);
    void setWoodImage(int index, const QString& ImagePath);  // Image 获取方式未知 （ 通过点击 TableWidget获取当前行的信息 获取ImagePath）

    QList<QString> readJsonPath(const QString& fileName);

private:
    Ui::WorkHisForm *ui;

    QStringList m_header;
    int m_currBatchID = -1;
    QString m_currBatchName = "";

    Message *m_pMsg;
    QString m_CurTabItemID = "";
    QList<T_BatchLine> m_HisDataList;
    QMap<int, QString> m_ImgPathMap;
    QThread *m_calcThread;
    WorkHisAvgThread *m_calcAvgWork;

    unsigned int m_currPageNum = 1;     // 当前页数
    unsigned int m_toalPageNum = 0;     // 总页数


};

class WorkHisAvgThread : public QObject
{
    Q_OBJECT
public:
    explicit WorkHisAvgThread(QObject *parent = nullptr);

    void working(QList<T_BatchLine> &list);

signals:
    void signal_calcSeccsess(T_BatchLine avgData);

private:


};

#include <QScrollArea>
#include <QWheelEvent>

class MyScrollArea : public QScrollArea
{
    Q_OBJECT
public:
    explicit MyScrollArea(QWidget *parent = nullptr);

protected:
    void wheelEvent(QWheelEvent *event) override;

signals:
};


#endif // WORKHISFORM_H
